﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HF.WorkFlow.StatData;
using HF.Framework.Windows;
using HF.WorkFlow.Engine;
using System.Windows.Forms.DataVisualization.Charting;
namespace HF.WorkFlow.StatChart
{
     [OutMethods("fmStatMain")]
    public partial class fmStatMain : Form
    {
        public fmStatMain()
        {
            InitializeComponent();
        }
        public fmStatMain(string NodeId, string userId, string userName)
        {
            InitializeComponent();
        }
        private void chart1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            chart1.DataSource = WorkFlowStat.GetWorkTaskByUserStat();
            chart1.ChartAreas.Clear();
            chart1.Series.Clear();
            chart1.Titles.Clear();
            //创建一个Area
            ChartArea defaultArea = new ChartArea();
            defaultArea.Name = "Default";
            defaultArea.AxisY.Title = "任务数量";
            defaultArea.AxisX.Interval = 1;
            chart1.ChartAreas.Add(defaultArea);
            //创建一个Serie
            Series defaultSerie = new Series();
            defaultSerie.Name = "Default";
            defaultSerie.IsValueShownAsLabel = true;
            defaultSerie.XValueMember = "username";
            defaultSerie.YValueMembers = "taskcount";
            chart1.Series.Add(defaultSerie);

            //创建一个Title
            Title defaultTitle = new Title();
            defaultTitle.Text = "任务处理数量统计";
            defaultTitle.Alignment = System.Drawing.ContentAlignment.TopCenter;
            defaultTitle.Font = new System.Drawing.Font("Trebuchet MS", 14.25F, System.Drawing.FontStyle.Bold);
            defaultTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
            defaultTitle.Name = "Title1";
            defaultTitle.ShadowColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
            defaultTitle.ShadowOffset = 3;
            chart1.Titles.Add(defaultTitle);

            chart1.DataBind();

            //chart1.Series["Default"].XValueMember = "username";
            //chart1.Series["Default"].YValueMembers = "taskcount";
            //chart1.ChartAreas["Default"].AxisX.Interval=1;
            //chart1.DataBind();

            //chart2.DataSource = WorkFlowStat.GetWorkTaskByUserStat();
            //chart2.Series["Default"].XValueMember = "username";
            //chart2.Series["Default"].YValueMembers = "taskcount";
            //chart2.ChartAreas["Default"].AxisX.Interval = 1;
            //chart2.DataBind();
        }

        private void chart1_AxisScrollBarClicked(object sender, System.Windows.Forms.DataVisualization.Charting.ScrollBarEventArgs e)
        {
            // Handle zoom reset button
            //if (e.ButtonType == ScrollBarButtonType.ZoomReset )
            //{
            //    // Event is handled, no more processing required
            //    e.IsHandled = true;

            //    // Reset zoom on X and Y axis
            //    chart1.ChartAreas["Default"].AxisX.ScaleView.ZoomReset();
            //    chart1.ChartAreas["Default"].AxisY.ScaleView.ZoomReset();
            //}
        }

        private void fmStatMain_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
          this.Text=  WorkFlowInstance.GetWorkFlowNO();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string varUser = "'50009'";
            this.Text = varUser.Trim('\'');
        }
    }
}
